package cn.yunhe.control;

import cn.yunhe.entity.Question;
import cn.yunhe.entity.Result;
import cn.yunhe.entity.Test;
import cn.yunhe.server.QuestionServer;
import cn.yunhe.server.ResultServer;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/SelectAllQuestionServlet")
public class SelectAllQuestionServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String tId = request.getParameter("tId");
        Test test = new Test();
        test.settId(Integer.parseInt(tId));
        Question question = new Question();
        question.setTest(test); //获取问题对象

        ResultServer resultServer = new ResultServer();
        List<Result> list = resultServer.SelectResult(question);
        request.setAttribute("resultList", list);
        request.getRequestDispatcher("allQuestion.jsp").forward(request, response);

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
